

//
//  NQiuzhiSecondStepViewController.m
//  nncloud
//
//  Created by macfai on 2018/12/14.
//  Copyright © 2018 macfai. All rights reserved.
//

#import "NQiuzhiSecondStepViewController.h"
#import "NQiuzhiThirdStepViewController.h"

@interface NQiuzhiSecondStepViewController ()<STPickerSingleDelegate,UITextFieldDelegate>

@property (weak, nonatomic) IBOutlet UILabel *xueliLabel;

@property (weak, nonatomic) IBOutlet UILabel *workPropertyLabel;

@property (weak, nonatomic) IBOutlet UILabel *jobExperinceLabel;

///行业意向
@property (weak, nonatomic) IBOutlet UILabel *industryLabel;

///职位意向
@property (weak, nonatomic) IBOutlet UILabel *zhiweiWillLabel;


@property (weak, nonatomic) IBOutlet UITextField *schoolTf;
///专业技能
@property (weak, nonatomic) IBOutlet UITextField *skillTf;
@property (weak, nonatomic) IBOutlet UITextField *zhuanYejinengTf;
@property (weak, nonatomic) IBOutlet UITextField *salaryTf;

@property (weak, nonatomic) IBOutlet UILabel *jobStatusLabel;

@end

@implementation NQiuzhiSecondStepViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.view.backgroundColor = kBackgroundColor;
    [self.navigationItem setItemWithTitle:@"求职信息" textColor:kNavigationTitleColor fontSize:18 itemType:center];
    
     [self addNavgationRightButtonWithFrame:CGRectMake(0, 0, 40, 35) title:@"下一步" Image:nil selectedIMG:nil tartget:self action:@selector(next)];
    // Do any additional setup after loading the view from its nib.
    
    
    [self addAction];
}

- (void)addAction{

    ///代理
    self.schoolTf.delegate = self;
    self.skillTf.delegate = self;
    self.zhuanYejinengTf.delegate =self;
    self.salaryTf.delegate = self;
    
    
    ///手势
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(chooseXueli:)];
    [self.xueliLabel addGestureRecognizer:tap];
    
    
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(chooseWorkproperty:)];
    [self.workPropertyLabel addGestureRecognizer:tap1];
    
    
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(choosejobExperince:)];
    [self.jobExperinceLabel addGestureRecognizer:tap2];
    
    
    
    UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(chooseindustry:)];
    [self.industryLabel addGestureRecognizer:tap3];
    
    
    
    UITapGestureRecognizer *tap4 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(choosezhiweiWill:)];
    [self.zhiweiWillLabel addGestureRecognizer:tap4];
    
    
    UITapGestureRecognizer *tap5 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(choosejobStatus:)];
    [self.jobStatusLabel addGestureRecognizer:tap5];
    
}


///选择学历
- (void)chooseXueli:(UITapGestureRecognizer *)tap
{
    YYLog(@"1");
    NSMutableArray *data = (NSMutableArray *)@[@"初中",@"高中",@"中专",@"大专",@"本科",@"硕士",@"博士",@"不限",];
    STPickerSingle *single = [[STPickerSingle alloc]init];
    single.tag = 131;
    [single setArrayData:data];
    [single setTitleUnit:@""];
    [single setDelegate:self];
    [single show];
}

////0:不限，1:全职，2:兼职，3:实习
- (void)chooseWorkproperty:(UITapGestureRecognizer *)tap

{
    
    [self.view endEditing:YES];
     YYLog(@"2");
    NSMutableArray *data = (NSMutableArray *)@[@"全职",@"兼职",@"实习",@"不限",];
    STPickerSingle *single = [[STPickerSingle alloc]init];
    single.tag = 132;
    [single setArrayData:data];
    [single setTitleUnit:@""];
    [single setDelegate:self];
    [single show];
}

///工作经验
- (void)choosejobExperince:(UITapGestureRecognizer *)tap
{
     YYLog(@"3");
    NSMutableArray *data = (NSMutableArray *)@[@"1年以下",@"1年以上",@"2年以上",@"3年以上",@"4年以上",@"5年以上",@"不限",];
    STPickerSingle *single = [[STPickerSingle alloc]init];
    single.tag = 133;
    [single setArrayData:data];
    [single setTitleUnit:@""];
    [single setDelegate:self];
    [single show];
}
//行业意向  0:不限，1:机械装备制造，2:电子信息，3:铝深加工，4:食品加工，5:生物制药，6:清洁能源，7:其他行业
- (void)chooseindustry:(UITapGestureRecognizer *)tap
{
    YYLog(@"4");
    NSMutableArray *data = (NSMutableArray *)@[@"机械装备制造",@"电子信息",@"铝深加工",@"食品加工",@"生物制药",@"清洁能源",@"其他行业",@"不限",];
    STPickerSingle *single = [[STPickerSingle alloc]init];
    single.tag = 134;
    [single setArrayData:data];
    [single setTitleUnit:@""];
    [single setDelegate:self];
    [single show];
}
//职位意向 0:不限，1:经营管理类，2:行政/人事/后勤类，3:财务/税务/审计类，4:生产制造/工工管理类，5:市场/销售类，6:客服/计算机服务类，7:计算机/互联网类，8:科研/咨询类，9:证券/金融/投资类，10:其他类

- (void)choosezhiweiWill:(UITapGestureRecognizer *)tap
{
    YYLog(@"5");
    NSMutableArray *data = (NSMutableArray *)@[@"经营管理类",@"行政/人事/后勤类",@"财务/税务/审计类",@"生产制造/工工管理类",@"市场/销售类",@"客服/计算机服务类",@"计算机/互联网类",@"科研/咨询类",@"证券/金融/投资类",@"科研/咨询类",@"证券/金融/投资类",@"其他类",@"不限",];
    STPickerSingle *single = [[STPickerSingle alloc]init];
    single.tag = 135;
    [single setArrayData:data];
    [single setTitleUnit:@""];
    [single setDelegate:self];
    [single show];
}
 //0:目前正在找工作,1:观望有好机会会考虑,2:目前不想换工作
- (void)choosejobStatus:(UITapGestureRecognizer *)tap
{
    YYLog(@"6");
    NSMutableArray *data = (NSMutableArray *)@[@"目前正在找工作",@"观望有好机会会考虑",@"目前不想换工作",@"不限",];
    STPickerSingle *single = [[STPickerSingle alloc]init];
    single.tag = 136;
    [single setArrayData:data];
    [single setTitleUnit:@""];
    [single setDelegate:self];
    [single show];
}

#pragma mark - pickerSingle delegate
-(void)pickerSingle:(STPickerSingle *)pickerSingle selectedTitle:(NSString *)selectedTitle selectIndex:(NSInteger)selectIndex{
    switch (pickerSingle.tag) {
            
        case 131:
        {
            self.xueliLabel.text = selectedTitle;
            [NGlobalModel shareInstance].xueli = [NSString stringWithFormat:@"%ld",selectIndex];
        }
            break;
            
        case 132:
        {
            self.workPropertyLabel.text = selectedTitle;
             [NGlobalModel shareInstance].jobProperty = [NSString stringWithFormat:@"%ld",selectIndex];
        }
            break;
        case 133:
        {
            self.jobExperinceLabel.text = selectedTitle;
            [NGlobalModel shareInstance].experince = [NSString stringWithFormat:@"%ld",selectIndex];
        }
            break;
        case 134:
        {
            self.industryLabel.text = selectedTitle;
            [NGlobalModel shareInstance].industryWill = [NSString stringWithFormat:@"%ld",selectIndex];
        }
            break;
        case 135:
        {
            self.zhiweiWillLabel.text = selectedTitle;
            [NGlobalModel shareInstance].jobWill = [NSString stringWithFormat:@"%ld",selectIndex];
        }
            break;
        case 136:
        {
            self.jobStatusLabel.text = selectedTitle;
            [NGlobalModel shareInstance].jobStatus = [NSString stringWithFormat:@"%ld",selectIndex];
        }
            break;
            
        default:
            break;
    }
}
//- (void)pickerSingle:(STPickerSingle *)pickerSingle selectedTitle:(NSString *)selectedTitle{
//    switch (pickerSingle.tag) {
//
//        case 131:
//            {
//                self.xueliLabel.text = selectedTitle;
//            }
//            break;
//
//        case 132:
//        {
//            self.workPropertyLabel.text = selectedTitle;
//        }
//            break;
//        case 133:
//        {
//            self.jobExperinceLabel.text = selectedTitle;
//        }
//            break;
//        case 134:
//        {
//            self.industryLabel.text = selectedTitle;
//        }
//            break;
//        case 135:
//        {
//            self.zhiweiWillLabel.text = selectedTitle;
//        }
//            break;
//        case 136:
//        {
//            self.jobStatusLabel.text = selectedTitle;
//        }
//            break;
//
//        default:
//            break;
//    }
//
//}

#pragma mark - textField delegate
- (void)textFieldDidEndEditing:(UITextField *)textField{
    
    if (textField==self.schoolTf) {
        [NGlobalModel shareInstance].school = textField.text;
        
    }else if (textField==self.skillTf){
        
        [NGlobalModel shareInstance].profession = textField.text;
    }else if (textField==self.zhuanYejinengTf){
        
        [NGlobalModel shareInstance].skill = textField.text;
        
    }else if (textField==self.salaryTf){
        
        [NGlobalModel shareInstance].salary = textField.text;
    }
    
}

#pragma mark - 字数限制
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    
    if (textField == self.schoolTf) {
        //这里的if为了获取删除操作,如果没有次if会造成当达到字数限制后删除键也不能使用的后果.
        if (range.length == 1 && string.length == 0) {
            return YES;
        }
        else if (self.schoolTf.text.length >= 30) {
            self.schoolTf.text = [textField.text substringToIndex:30];
            return NO;
        }
    }else if (textField==self.skillTf){
        if (range.length == 1 && string.length == 0) {
            return YES;
        }
        else if (self.skillTf.text.length >= 30) {
            self.skillTf.text = [textField.text substringToIndex:30];
            return NO;
        }
    }else if (textField==self.zhuanYejinengTf){
        
        if (range.length == 1 && string.length == 0) {
            return YES;
        }
        else if (self.zhuanYejinengTf.text.length >= 30) {
            self.zhuanYejinengTf.text = [textField.text substringToIndex:30];
            return NO;
        }
    }

    return YES;
    
}

- (BOOL)isOkWordNumber:(NSString *)string{
    return  [ToolKit judgeChineseWord:string];
}
///
- (void)next{
    
    NQiuzhiThirdStepViewController *sec = [NQiuzhiThirdStepViewController new];
    [self.navigationController pushViewController:sec animated:YES];
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
